﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MSBDATAModel;

public partial class Admin_Default : System.Web.UI.Page
{
    MSBDATAEntities entities = new MSBDATAEntities();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["admin"] != null)
            {
                Session["admin"] = null;
            }
        }
    }
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        try
        {
            string adminName = this.TextBoxTen.Text;
            string pass = this.TextBoxMatKhau.Text;

            C_ADMIN a = entities.C_ADMIN.First(c => c.TenDangNhap == adminName);
            if (a.MatKhau == pass)
            {
                Session["admin"] = true;
                Response.Redirect("Admin.aspx");
            }
            else {
                this.LabelStatus.Text = "Mật khẩu sai";
            }
        }
        catch (Exception) { 
            
        }
    }
}